home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / MSCDEX.ASM < prev    next >
Assembly Source File  |  1992-12-09  |  11KB  |  705 lines

  1.     page 64, 131
  2.     title mscdex.asm - interface to mscdex interrupt 2F
  3.  
  4. ;   /*\
  5. ;---|*|----====< mscdex.asm >====----
  6. ;---|*|
  7. ;---|*| routines for c-interface to mscdex
  8. ;---|*| support for those functions defined in mscdex v(2.
  9. ;---|*|
  10. ;---|*| Copyright (c) 1992, Media Vision, Inc.    All Rights Reserved
  11. ;---|*|
  12. ;   \*/
  13.  
  14.     .xlist 
  15.     include model.inc
  16.     include masm.inc
  17.     .list
  18.  
  19. if MODELSIZE eq 0
  20.     .code
  21. else
  22.     .data
  23. endif
  24.  
  25. ;; this holds the last value returned with carry set from int 2F
  26.     public lasterror
  27. lasterror    dw 0
  28.  
  29.     .code
  30.  
  31. ;   /*\
  32. ;---|*|----====< int ismscdex(void) >====----
  33. ;---|*|
  34. ;---|*| Entry:
  35. ;---|*|
  36. ;---|*|    none
  37. ;---|*|
  38. ;---|*| Exit:
  39. ;---|*|
  40. ;---|*|    return TRUE (not zero) if mscdex exists,
  41. ;---|*|    else FALSE (zero)
  42. ;---|*|
  43. ;   \*/
  44.  
  45.     public    ismscdex
  46. ismscdex    proc
  47.     push bp
  48.     mov bp, sp
  49.  
  50.     mov ax, 1500h            ; is function 15h available?
  51.     xor bx, bx
  52.     int 2Fh
  53.  
  54.     xor ax, ax            ; ready to return 0
  55.  
  56.     or bx, bx            ; does mscdex report available?
  57.     jz done                ; not here, return 0
  58.  
  59.     inc ax                ; yes here, return 1
  60.  
  61. done:
  62.     pop bp
  63.     ret
  64. ismscdex    endp
  65.  
  66.  
  67. ;   /*\
  68. ;---|*|----====< int getnumcdroms(void) >====----
  69. ;---|*|
  70. ;---|*| Entry:
  71. ;---|*|
  72. ;---|*|    none
  73. ;---|*|
  74. ;---|*| Exit:
  75. ;---|*|
  76. ;---|*|    return total count of cdrom drives in system
  77. ;---|*|
  78. ;   \*/
  79.  
  80.     public    getnumcdroms
  81. getnumcdroms    proc
  82.     push bp
  83.     mov bp, sp
  84.  
  85.     mov ax, 1500h
  86.     xor bx, bx
  87.     int 2Fh
  88.  
  89.     mov ax, bx
  90.     pop bp
  91.     ret
  92. getnumcdroms    endp
  93.  
  94. ;   /*\
  95. ;---|*|----====< int getfirstcdrom(void) >====----
  96. ;---|*|
  97. ;---|*| Entry:
  98. ;---|*|
  99. ;---|*|    none
  100. ;---|*|
  101. ;---|*| Exit:
  102. ;---|*|
  103. ;---|*|    return number of first cdrom drive
  104. ;---|*|
  105. ;   \*/
  106.  
  107.     public getfirstcdrom
  108. getfirstcdrom    proc
  109.     push bp
  110.     mov bp, sp
  111.  
  112.     mov ax, 1500h
  113.     xor bx, bx
  114.     int 2Fh
  115.  
  116.     mov ax, cx
  117.  
  118.     pop bp
  119.     ret
  120. getfirstcdrom endp
  121.  
  122. ;   /*\
  123. ;---|*|----====< int getcdromlist(struct cdromdrivestruct far *cdromlist) >====----
  124. ;---|*|
  125. ;---|*|     fill buffer with drive identifiers and addresses
  126. ;---|*|
  127. ;---|*| Entry:
  128. ;---|*|
  129. ;---|*|    address of buffer
  130. ;---|*|
  131. ;---|*| Exit:
  132. ;---|*|
  133. ;---|*|    0 if successful, -1 if error occurred
  134. ;---|*|
  135. ;   \*/
  136.  
  137.     public getcdromlist
  138. getcdromlist proc
  139.     push bp
  140.     mov bp, sp
  141.  
  142.     mov ax, 1501h
  143.     les bx, dParm1
  144.     int 2Fh
  145.  
  146.     pop bp
  147.     ret
  148. getcdromlist endp
  149.  
  150. ;   /*\
  151. ;---|*|----====< int getcopyrightfname(int drive, char far *copyrightfname) >====----
  152. ;---|*|
  153. ;---|*|     fill buffer with name of copyright file for drive
  154. ;---|*|
  155. ;---|*| Entry:
  156. ;---|*|
  157. ;---|*|    drive number, address of buffer
  158. ;---|*|
  159. ;---|*| Exit:
  160. ;---|*|
  161. ;---|*|    0 if successful, -1 if error occurred
  162. ;---|*|
  163. ;   \*/
  164.  
  165.     public getcopyrightfname
  166. getcopyrightfname proc
  167.     push bp
  168.     mov bp, sp
  169.  
  170.     mov ax, 1502h
  171.     mov cx, wParm1
  172.     les bx, wParm2
  173.     int 2Fh
  174.     jnc okay
  175.  
  176.     mov lasterror, ax
  177.     mov ax, -1
  178.     jmp short done
  179.  
  180. okay:
  181.     xor ax, ax
  182.  
  183. done:
  184.     pop bp
  185.     ret
  186. getcopyrightfname endp
  187.  
  188. ;   /*\
  189. ;---|*|----====< int getabstractfname(int drive, char far *abstractfname) >====----
  190. ;---|*|
  191. ;---|*|     fill buffer with name of abstract file for drive
  192. ;---|*|
  193. ;---|*| Entry:
  194. ;---|*|
  195. ;---|*|    drive number, address of buffer
  196. ;---|*|
  197. ;---|*| Exit:
  198. ;---|*|
  199. ;---|*|    0 if successful, -1 if error occurred
  200. ;---|*|
  201. ;   \*/
  202.  
  203.     public getabstractfname
  204. getabstractfname proc
  205.     push bp
  206.     mov bp, sp
  207.  
  208.     mov ax, 1503h
  209.     mov cx, wParm1
  210.     les bx, wParm2
  211.     int 2Fh
  212.     jnc okay
  213.  
  214.     mov lasterror, ax
  215.     mov ax, -1
  216.     jmp short done
  217.  
  218. okay:
  219.     xor ax, ax
  220.  
  221. done:
  222.     pop bp
  223.     ret
  224. getabstractfname endp
  225.         
  226.  
  227. ;   /*\
  228. ;---|*|----====< int getbibliofname(int drive, char far *bibliofname) >====----
  229. ;---|*|
  230. ;---|*|     fill buffer with name of bibliographic file for drive
  231. ;---|*|
  232. ;---|*| Entry:
  233. ;---|*|
  234. ;---|*|    drive number, address of buffer
  235. ;---|*|
  236. ;---|*| Exit:
  237. ;---|*|
  238. ;---|*|    0 if successful, -1 if error occurred
  239. ;---|*|
  240. ;   \*/
  241.  
  242. getbibliofname proc
  243.     push bp
  244.     mov bp, sp
  245.  
  246.     mov ax, 1504h
  247.     mov cx, wParm1
  248.     les bx, wParm2
  249.     int 2Fh
  250.     jnc okay
  251.  
  252.     mov lasterror, ax
  253.     mov ax, -1
  254.     jmp short done
  255.  
  256. okay:
  257.     xor ax, ax
  258.  
  259. done:
  260.     pop bp
  261.     ret
  262. getbibliofname endp
  263.  
  264. ;   /*\
  265. ;---|*|----====< int readvtoc(int drive, int index, char far *dscbuf) >====----
  266. ;---|*|
  267. ;---|*|     read entry from volume table of contents for drive
  268. ;---|*|
  269. ;---|*| Entry:
  270. ;---|*|
  271. ;---|*|    drive number, entry number, address of buffer
  272. ;---|*|
  273. ;---|*| Exit:
  274. ;---|*|
  275. ;---|*|    return type of descriptor read, or -2 if error
  276. ;---|*|
  277. ;   \*/
  278.  
  279.     public readvtoc
  280. readvtoc proc
  281.     push bp
  282.     mov bp, sp
  283.  
  284.     mov ax, 1505h
  285.     mov cx, wParm1
  286.     mov dx, wParm2
  287.     les bx, wParm3
  288.     int 2Fh
  289.     jnc okay
  290.  
  291.     mov lasterror, ax
  292.     mov ax, -2
  293.  
  294. okay:
  295.     cbw
  296.  
  297.     pop bp
  298.     ret
  299. readvtoc endp
  300.  
  301. ;   /*\
  302. ;---|*|----====< int absdiscread(int drive, int count, long sector, char far *buffer) >====----
  303. ;---|*|
  304. ;---|*|     read one or more logical sectors for drive
  305. ;---|*|
  306. ;---|*| Entry:
  307. ;---|*|
  308. ;---|*|    drive number, count of sectors,
  309. ;---|*|         starting sector number, address of buffer for data
  310. ;---|*|
  311. ;---|*| Exit:
  312. ;---|*|
  313. ;---|*|    returns count of sectors read, -1 if error
  314. ;---|*|
  315. ;   \*/
  316.  
  317.     public absdiscread
  318. absdiscread proc
  319.     push bp
  320.     mov bp, sp
  321.     push si
  322.     push di
  323.  
  324.     mov ax, 1508h
  325.     mov cx, wParm1
  326.     mov dx, wParm2
  327.     mov di, wParm3
  328.     mov si, wParm4
  329.     les bx, wParm5
  330.     int 2Fh
  331.     jnc okay
  332.  
  333.     mov lasterror, ax
  334.     mov ax, -1
  335.     jmp short done
  336.  
  337. okay:
  338.     mov ax, wParm2
  339.  
  340. done:
  341.     pop di
  342.     pop si
  343.     pop bp
  344.     ret
  345. absdiscread endp
  346.  
  347. ;   /*\
  348. ;---|*|----====< int absdiscwrite(int drive, int count, long sector, char far *buffer) >====----
  349. ;---|*|
  350. ;---|*|     write one or more logical sectors for drive
  351. ;---|*|
  352. ;---|*| Entry:
  353. ;---|*|
  354. ;---|*|    drive number, count of sectors to write,
  355. ;---|*|    starting sector, address of buffer
  356. ;---|*|
  357. ;---|*| Exit:
  358. ;---|*|
  359. ;---|*|    returns count of sectors written, -1 if error
  360. ;---|*|
  361. ;   \*/
  362.  
  363.     public absdiscwrite
  364. absdiscwrite proc
  365.     push bp
  366.     mov bp, sp
  367.     push si
  368.     push di
  369.  
  370.     mov ax, 1509h
  371.     mov cx, wParm1
  372.     mov dx, wParm2
  373.     mov di, wParm3
  374.     mov si, wParm4
  375.     les bx, wParm5
  376.     int 2Fh
  377.     jnc okay
  378.  
  379.     mov lasterror, ax
  380.     mov ax, -1
  381.     jmp short done
  382.  
  383. okay:
  384.     mov ax, wParm2
  385.  
  386. done:
  387.     pop di
  388.     pop si
  389.     pop bp
  390.     ret
  391. absdiscwrite endp
  392.  
  393. ;   /*\
  394. ;---|*|----====< int chkdrive(int drive) >====----
  395. ;---|*|
  396. ;---|*|     check if drive supported by mscdex
  397. ;---|*|
  398. ;---|*| Entry:
  399. ;---|*|
  400. ;---|*|    drive number
  401. ;---|*|
  402. ;---|*| Exit:
  403. ;---|*|
  404. ;---|*|    return 0 if mscdex installed and drive is supported
  405. ;---|*|    return 1 if mscdex installed and drive not supported
  406. ;---|*|    return -1 if mscdex not installed
  407. ;---|*|
  408. ;   \*/
  409.  
  410.     public chkdrive
  411. chkdrive proc
  412.     push bp
  413.     mov bp, sp
  414.  
  415.     mov ax, 150Bh
  416.     mov bx, 0
  417.     mov cx, wParm1
  418.     int 2Fh
  419.  
  420.     cmp bx, 0ADADh
  421.     jnz nomscdex
  422.  
  423.     cmp ax, 0
  424.     jz notcdrom
  425.  
  426.     mov ax, 0
  427.     jmp short done
  428.  
  429. nomscdex:
  430.     mov ax, -1
  431.     jmp short done
  432.  
  433. notcdrom:
  434.     mov ax, 1
  435.  
  436. done:
  437.     pop bp
  438.     ret
  439. chkdrive endp
  440.  
  441. ;   /*\
  442. ;---|*|----====< int getmscdexversion(void) >====----
  443. ;---|*|
  444. ;---|*| Entry:
  445. ;---|*|
  446. ;---|*|    none
  447. ;---|*|
  448. ;---|*| Exit:
  449. ;---|*|
  450. ;---|*|    return version of mscdex
  451. ;---|*|
  452. ;   \*/
  453.  
  454.     public getmscdexversion
  455. getmscdexversion proc
  456.     push bp
  457.     mov bp, sp
  458.  
  459.     mov ax, 150Ch
  460.     xor bx, bx
  461.     int 2Fh
  462.  
  463.     mov ax, bx
  464.  
  465.     pop bp
  466.     ret
  467. getmscdexversion endp
  468.  
  469. ;   /*\
  470. ;---|*|----====< int getcdromunits(char far *cdromunits) >====----
  471. ;---|*|
  472. ;---|*|     fill buffer with list of cdrom drives
  473. ;---|*|
  474. ;---|*| Entry:
  475. ;---|*|
  476. ;---|*|    address of buffer
  477. ;---|*|
  478. ;---|*| Exit:
  479. ;---|*|
  480. ;---|*|    none
  481. ;---|*|
  482. ;   \*/
  483.  
  484.     public getcdromunits
  485. getcdromunits proc
  486.     push bp
  487.     mov bp, sp
  488.  
  489.     mov ax, 150Dh
  490.     les bx, dParm1
  491.     int 2Fh
  492.  
  493.     pop bp
  494.     ret
  495. getcdromunits endp
  496.  
  497. ;   /*\
  498. ;---|*|----====< int getvdescpref(int drive) >====----
  499. ;---|*|
  500. ;---|*|     get preference for primary or supplementary descriptors
  501. ;---|*|
  502. ;---|*| Entry:
  503. ;---|*|
  504. ;---|*|    drive number
  505. ;---|*|
  506. ;---|*| Exit:
  507. ;---|*|
  508. ;---|*|    return 0 or 1 (preference), or -1 if error
  509. ;---|*|
  510. ;   \*/
  511.  
  512.     public getvdescpref
  513. getvdescpref proc
  514.     push bp
  515.     mov bp, sp
  516.  
  517.     mov ax, 150Eh
  518.     xor bx, bx
  519.     mov cx, wParm1
  520.     int 2Fh
  521.     jnc okay
  522.  
  523.     mov lasterror, ax
  524.     mov ax, -1
  525.  
  526. okay:
  527.     pop bp
  528.     ret
  529. getvdescpref endp
  530.  
  531. ;   /*\
  532. ;---|*|----====< int setvdescpref(int drive, int pref) >====----
  533. ;---|*|
  534. ;---|*|     set preference for primary or supplementary descriptors
  535. ;---|*|
  536. ;---|*| Entry:
  537. ;---|*|
  538. ;---|*|    drive number, preference (0 primary, 1 secondary)
  539. ;---|*|
  540. ;---|*| Exit:
  541. ;---|*|
  542. ;---|*|    return 0 if successful, -1 if error occurred
  543. ;---|*|
  544. ;   \*/
  545.  
  546.     public setvdescpref
  547. setvdescpref proc
  548.     push bp
  549.     mov bp, sp
  550.  
  551.     mov ax, 150Eh
  552.     mov bx, 1
  553.     mov cx, wParm1
  554.     mov dx, wParm2
  555.  
  556.     cmp dh, 1
  557.     jnz isvalid
  558.     cmp dl, 0
  559.     jnz invalid
  560.  
  561. isvalid:
  562.     int 2Fh
  563.     jnc okay
  564.  
  565.     mov lasterror, ax
  566.  
  567. invalid:
  568.     mov ax, -1
  569.     jmp short done
  570.  
  571. okay:
  572.     xor ax, ax
  573.  
  574. done:
  575.     pop bp
  576.     ret
  577. setvdescpref endp
  578.  
  579. ;   /*\
  580. ;---|*|----====< int getdirentry(int drive, char far *name, char far *buffer) >====----
  581. ;---|*|
  582. ;---|*|     search directory for entry, fill buffer if found
  583. ;---|*|
  584. ;---|*| Entry:
  585. ;---|*|
  586. ;---|*|    drive number, address of file name, address of buffer
  587. ;---|*|
  588. ;---|*| Exit:
  589. ;---|*|
  590. ;---|*|    return format of volume, -1 if error
  591. ;---|*|
  592. ;   \*/
  593.  
  594.     public getdirentry
  595. getdirentry proc
  596.     push bp
  597.     mov bp, sp
  598.     push si
  599.     push di
  600.  
  601.     mov ax, 150Fh
  602.     mov cx, wParm1
  603.     les bx, wParm2
  604.     mov di, wParm4
  605.     mov si, wParm5
  606.     int 2Fh
  607.     jnc okay
  608.  
  609.     mov lasterror, ax
  610.     mov ax, -1
  611.  
  612. okay:
  613.     pop di
  614.     pop si
  615.     pop bp
  616.     ret
  617. getdirentry endp
  618.  
  619. ;   /*\
  620. ;---|*|----====< int senddevreq(int drive, void far *cdh) >====----
  621. ;---|*|
  622. ;---|*|     send device request
  623. ;---|*|
  624. ;---|*| Entry:
  625. ;---|*|
  626. ;---|*|    drive number, address of buffer
  627. ;---|*|
  628. ;---|*| Exit:
  629. ;---|*|
  630. ;---|*|    none (status placed in buffer by driver)
  631. ;---|*|
  632. ;   \*/
  633.  
  634.     public senddevreq
  635. senddevreq proc
  636.     push bp
  637.     mov bp, sp
  638.  
  639.     mov ax, 1510h
  640.     mov cx, wParm1
  641.     les bx, wParm2
  642.     int 2Fh
  643.  
  644.     pop bp
  645.     ret
  646. senddevreq endp
  647.  
  648. ;   /*\
  649. ;---|*|----====< int getlasterror(void) >====----
  650. ;---|*|
  651. ;---|*|     return value in lasterror
  652. ;---|*|
  653. ;---|*| Entry:
  654. ;---|*|
  655. ;---|*|    none
  656. ;---|*|
  657. ;---|*| Exit:
  658. ;---|*|
  659. ;---|*|    last error value saved
  660. ;---|*|
  661. ;   \*/
  662.  
  663.     public getlasterror
  664. getlasterror proc
  665.     push bp
  666.     mov bp, sp
  667.  
  668.     mov ax, lasterror
  669.  
  670.     pop bp
  671.     ret
  672. getlasterror endp
  673.  
  674. ;   /*\
  675. ;---|*|----====< int clearlasterror(void) >====----
  676. ;---|*|
  677. ;---|*| Entry:
  678. ;---|*|
  679. ;---|*|    none
  680. ;---|*|
  681. ;---|*| Exit:
  682. ;---|*|
  683. ;---|*|    last saved error value
  684. ;---|*|
  685. ;   \*/
  686.  
  687.     public clearlasterror
  688. clearlasterror proc
  689.     push bp
  690.     mov bp, sp
  691.  
  692.     xor ax, ax
  693.     xchg lasterror, ax
  694.  
  695.     pop bp
  696.     ret
  697. clearlasterror endp
  698.  
  699. ;   /*\
  700. ;---|*| end of MSCDEX.ASM
  701. ;   \*/
  702.  
  703.     end
  704.  
  705.